<?php


namespace app\controllers;


use app\service\UserService;
use srcker\Captcha;

class CaptchaController  extends BaseJsonController
{
    public function doService($req, $userInfo)
    {
        $config  = [];
        $captcha = new Captcha($config);
        $data = $captcha->entry();
        $session = \Yii::$app->session;
        $session->set("captcha",$data["code"]);

        $redis = UserService::getRedis();
        $redis->set($session->getId(),$data["code"]);

        return ["base64"=>$data["base64"],"id"=>$session->getId()];
    }

    public function needLogin()
    {
        return false;
    }


}